package com.shd.edanpei.ui.adapter.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.bigkoo.convenientbanner.holder.Holder;
import com.shd.edanpei.R;
import com.shd.edanpei.image.LoadImageCtrl;

/**
 * Created by mc on 2018/9/18.
 * yang-wen-wen
 */

public class BannerHolder implements CBViewHolderCreator {

    private final LoadImageCtrl loadImageCtrl;

    public BannerHolder(Context context) {
        this.loadImageCtrl = new LoadImageCtrl(context);
    }

    @Override
    public Holder createHolder(View view) {
        return new ImageHolderView(view, loadImageCtrl);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_banner;
    }

    public class ImageHolderView extends Holder<String> {
        private ImageView imageView;
        private final LoadImageCtrl loadImageCtrl;

        public ImageHolderView(View itemView, LoadImageCtrl loadImageCtrl) {
            super(itemView);
            this.loadImageCtrl = loadImageCtrl;
        }


        @Override
        protected void initView(View view) {
            imageView = itemView.findViewById(R.id.ivPost);
        }

        @Override
        public void updateUI(String s) {
            loadImageCtrl.getGlide().load(s).into(imageView);
        }


    }
}
